<template>
  <view class="richText-page bg-white">
    <u-parse :content="content" :tag-style="tagStyle"></u-parse>
  </view>
</template>
<script setup>
import { onLoad } from "@dcloudio/uni-app";
import { ref, getCurrentInstance } from "vue";
const instance = getCurrentInstance().proxy;

const tagStyle = ref({});
const content = ref("");
const title = ref("");
onLoad((option) => {
  // 两种接收参数参方式
  // 1. 直接传参
  title.value = option.title;
  content.value = option.data;
  // 设置标题
  uni.setNavigationBarTitle({
    title: title.value || '详情'
  });


  // 2/3. 通过事件参数跳转到通用富文本页面
  const eventChannel = instance.getOpenerEventChannel();
  eventChannel.on('richText', (data) => {
    title.value = data.title;
    content.value = data.data;
    // 设置标题
    uni.setNavigationBarTitle({
      title: title.value || '详情'
    })
  });
});
</script>
<style lang='scss' scoped>
.richText-page {
  padding: 10px;
}
</style>
